/**************************************************************************
File:        stepper.h
Description: Include file for stepper motor class
 
Copyright:   (C) 1998-2012 by ZJ Laczik
Email:       Zsolt.Laczik@eng.ox.ac.uk
****************************************************************************
Change log:
   begin      19/11/1998
   15/2/2012	QT4 update
***************************************************************************/

#ifndef STEPPER_H
#define STEPPER_H

#include <QObject>
#include <QWidget>

#define X_AX 1
#define Y_AX 2
#define Z_AX 3

// class declaration
//==================
class Stepper : public QObject  {
	Q_OBJECT
public:
	Stepper(QWidget *parent=0);
	~Stepper();
  
	void SetStopFlagPointer(bool * pSF);
	void StepRel(long int steps, int axes);
	void StepAbs(long int steps, int axes);
	long int GetPos(int axes);
public slots:
	void SetPos(long int newpos, int axes);
	void slotSetMinFreq(int freq);
	void slotSetMaxFreq(int freq);
	void slotSetFreqIncr(int freq);
	void slotSetPulseWidth(long int pw);
signals:
	void Position(float x, float y, float z);
	void sigMinFreqChanged(int freq);
	void sigMaxFreqChanged(int freq);
	void sigFreqIncrChanged(int freq);
	void sigPulseWidthChanged(long int pw);
private:
	int mMinFreq;
	int mMaxFreq;
	int mFreqIncr;
	long int mPulseWidth;
	long int mSpace;
	long int mMinPeriod;
	long int mMaxPeriod;
	long int mPeriodIncr;
	long int ppdev ;
	long int current_pos[4];
	bool StopFlag;
	bool * pStopFlag;
	void usec_delay(long int usecs);
	void one_step(bool forward, int axes);
};
#endif
